//
//  ViewController.m
//  CropImg
//
//  Created by lipeng on 16/3/7.
//  Copyright © 2016年 lipeng. All rights reserved.
//

#import "ViewController.h"
#import "StickerVCtler.h"
#import "CMPushAnimation.h"

#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self;

@interface ViewController ()<UINavigationControllerDelegate>
{
    CMPushAnimation *cmPush;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    UIImageView *imgV = UIImageView.new;
    imgV.backgroundColor = UIColor.greenColor;
    imgV.image = [UIImage imageNamed:@"Google.jpg"];
    [self.view addSubview:imgV];
    
    UIButton *btnEditer = UIButton.new;
    [btnEditer setTitle:@"Add Pasters" forState:UIControlStateNormal];
    btnEditer.backgroundColor = [UIColor blackColor];
    [self.view addSubview:btnEditer];
    
    [btnEditer addTarget:self
                  action:@selector(btnEditer_Event:)
        forControlEvents:UIControlEventTouchUpInside];
    
    
//    WS(ws);
    
    [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20);
        make.centerX.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(300, 300));
    }];
    
    [btnEditer mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(imgV.bottom).offset(20);
        make.centerX.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(120, 40));
    }];
 
    
    self.navigationController.delegate = self;
    cmPush = [[CMPushAnimation alloc]init];
    
}

-(void)btnEditer_Event:(id)sender
{
    StickerVCtler *vc = [StickerVCtler new];
    [self.navigationController pushViewController:vc animated:YES];
}

- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                            animationControllerForOperation:(UINavigationControllerOperation)operation
                                                         fromViewController:(UIViewController *)fromVC
                                                           toViewController:(UIViewController *)toVC
{
    if(operation == UINavigationControllerOperationPush || operation == UINavigationControllerOperationPop)
        return  cmPush;
    else
        return nil;
}

@end
